from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from logging import config as logger_config
from utils.log_config import config as log_config
import logging

logger_config.dictConfig(log_config)

from app.routers import items

logger = logging.getLogger(__name__)

logger.info("Starting the application...")
app = FastAPI()

origins = [
    "http://localhost:3000",
    "http://192.168.16.171:3000",
]

app.add_middleware(
    CORSMiddleware,
    allow_origins=origins,
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

app.include_router(items.router)

if __name__ == "__main__":
    import uvicorn
    uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True, log_level="info")